package org.zhangyp.n03algorithm.n01Time;

/**
 * 计算时间复杂度
 *
 * @author zhangyp
 * @date 2023/6/7 10:42
 */
public class TimeDemo {

    public static void main(String[] args) {

        /*int count = 1; // 这一行代码只有一次计算，时间复杂度为O(1)

        for(int i = 0;i< 1000000;i++){
            count = count + 1;  // 虽然执行了1000000次，但只要是确定的常数，时间复杂度就是O(1)
        }*/
        //不要把 n 看成是常数，这里为了方便演示用Integer.MAX_VALUE表示一个不确定的数
        int n = Integer.MAX_VALUE;
        long count = 0;
        long num = (long) Math.pow(2,n);
        for (long i = 0; i < num; i++) {
            count = count + 1;
        }
        System.out.println(count);
        /*for (int i = 0; i < n; i++) {
            for (long j = 0; j < n; j ++) {
                count = count + 1;
            }
        }
        System.out.println(count);*/




        /*for (long i = 1; i < n; i = i * 2) {
            count = count + 1;
        }
        System.out.println(count);*/





        /*long num = 1;
        long j = 0;
        for (int i = 0; i < n; i++) {
            num = num * 2;
            for (; j < num; j++) {
                count = count + 1;
            }
        }
        System.out.println(count);*/
    }


}
